#encoding:utf8 

'''删除某一个类型的文件'''

import os, sys 

def iter_public(path, typename):
    for filename in os.listdir(path):
        fileobj = os.path.join(path , filename)
        if os.path.isfile(fileobj):
            if filename.endswith(typename):
                os.remove(fileobj)
                print ("Del the file-->>%s"%fileobj)
        else:
            iter_public(fileobj)

if __name__ == "__main__":
    print("================================================")
    print("==================Del type-files================")
    print("================================================")
    #type1 pack the ipa
    parser.add_option("-p", "--path", dest="delpath", help="Input the path for del the type-files!")
    parser.add_option("-t", "--type", dest="filetype", help="Del the file of type is.")

    (opts, args) = parser.parse_args()
    if (opts.delpath and opts.filetype):
        iter_public(opts.delpath, opts.filetype)
    else:
        logging.error("Input -p and -t parms!")